## - ## 

# Replication code for 

# Bailo, F. (2015). 
# Mapping online political talks through network analysis: 
# A case study of the website of Italy’s Five Star Movement. 
# Policy Studies, 36(6), 550–572. 

# Paper available at http://www.tandfonline.com/doi/full/10.1080/01442872.2015.1095282

# Contact: francesco.bailo@sydney.edu.au

## - ## - ## 


# Note: T
# This code removes usernames (also `authorUrl`) from data files of the replication package. 
# It is not meant to be run but is published only to explain how data were anomymised. 

# Anonymisation

unique_id <- unique(c(thread$authorUrl, comment$authorUrl))
anonym_id <- 1:length(unique_id)
names(anonym_id) <- unique_id

thread$authorUrl <- anonym_id[thread$authorUrl]
comment$authorUrl <- anonym_id[comment$authorUrl]
author_omega$id <- anonym_id[author_omega$id]

author_omega$name <- NULL

igraph_bi <- upgrade_graph(igraph_bi)
# FALSE indicates users, TRUE indicates threads
V(igraph_bi)$url[V(igraph_bi)$type == FALSE] <- 
  anonym_id[V(igraph_bi)$url[V(igraph_bi)$type == FALSE]]
V(igraph_bi)$name[V(igraph_bi)$type == FALSE] <- 
  V(igraph_bi)$url[V(igraph_bi)$type == FALSE]

# Trimming messages
thread$message <- strtrim(thread$message, 140)
comment$message <- strtrim(comment$message, 140)
comment$rawMessage <- NULL

save(thread, file = "m5sforum_feb2014_thread.RData")
save(comment, file = "m5sforum_feb2014_comment.RData")
save(author_omega, file = "m5sforum_feb2014_author.RData")
save(igraph_bi, file = "m5sforum_feb2014_bigraph.RData")
